package com.cn.controller;

import com.cn.pojo.PageResult;
import com.cn.pojo.RequestParams;
import com.cn.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private IHotelService hotelService;
    // 搜索酒店数据
    @PostMapping("/list")
    public PageResult search(@RequestBody RequestParams params){
        try {
            return hotelService.search(params);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @PostMapping("/filters")
    public Map<String, List<String>> getFilter(@RequestBody RequestParams params) throws IOException {
        return hotelService.getFilter(params);
    }
}